package com.xjd.transport;

import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.concurrent.ExecutorService;

public interface TransportServer {
	
	//==bindAddress
	void setBindPort(int port);
	void setBindAddress(String host, int port);
	void setBindAddress(InetSocketAddress bindAddress);
	
	InetSocketAddress getBindAddress();
	
	//==ExecutorService
	void setBossExecutorService(ExecutorService bossExecutorService);
	ExecutorService getBossExecutorService();
	
	void setWorkerExecutorService(ExecutorService workerExecutorService);
	ExecutorService getWorkerExecutorService();
	
	//==max channel
	void setMaxConnectedChannel(int maxConnected);
	int getMaxConnectedChannel();
	
	void setMaxWaitingChannel(int maxWaiting);
	int getMaxWaitingChannel();
	
	//==start and stop
	void start() throws TransportException;
	void stop();
	
	//==waiting channel
	/**
	 * @param timeoutInMills <0: 表无限等待
	 * @return
	 */
	Channel nextWaitChannel(long timeoutInMills);
	
	//audit and monitor
	boolean isRunning();
	Throwable getCause();
	Channel[] getConnectedChannels();
	Channel[] getWaitingChannels();
	Channel[] getConnectedChannelsFrom(InetAddress from);
	
}
